package com.sdhs.qualitymanage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.qualitymanage.domain.GcQuality;
import com.sdhs.qualitymanage.service.IGcQualityService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 质量管理-默认Controller
 *
 * @author add
 * @date 2025-04-11
 */
@RestController
@RequestMapping("/qualitymanage/quality")
public class GcQualityController extends BaseController
{
    @Autowired
    private IGcQualityService gcQualityService;

    /**
     * 查询质量管理-默认列表
     */
    @PreAuthorize("@ss.hasPermi('qualitymanage:quality:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcQuality gcQuality)
    {
        startPage();
        List<GcQuality> list = gcQualityService.selectGcQualityList(gcQuality);
        return getDataTable(list);
    }

    /**
     * 导出质量管理-默认列表
     */
    @PreAuthorize("@ss.hasPermi('qualitymanage:quality:export')")
    @Log(title = "质量管理-默认", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcQuality gcQuality)
    {
        List<GcQuality> list = gcQualityService.selectGcQualityList(gcQuality);
        ExcelUtil<GcQuality> util = new ExcelUtil<GcQuality>(GcQuality.class);
        util.exportExcel(response, list, "质量管理-默认数据");
    }

    /**
     * 获取质量管理-默认详细信息
     */
    @PreAuthorize("@ss.hasPermi('qualitymanage:quality:query')")
    @GetMapping(value = "/{qualityId}")
    public AjaxResult getInfo(@PathVariable("qualityId") Long qualityId)
    {
        return success(gcQualityService.selectGcQualityByQualityId(qualityId));
    }

    /**
     * 新增质量管理-默认
     */
    @PreAuthorize("@ss.hasPermi('qualitymanage:quality:add')")
    @Log(title = "质量管理-默认", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcQuality gcQuality)
    {
        return toAjax(gcQualityService.insertGcQuality(gcQuality));
    }

    /**
     * 修改质量管理-默认
     */
    @PreAuthorize("@ss.hasPermi('qualitymanage:quality:edit')")
    @Log(title = "质量管理-默认", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcQuality gcQuality)
    {
        return toAjax(gcQualityService.updateGcQuality(gcQuality));
    }

    /**
     * 删除质量管理-默认
     */
    @PreAuthorize("@ss.hasPermi('qualitymanage:quality:remove')")
    @Log(title = "质量管理-默认", businessType = BusinessType.DELETE)
	@DeleteMapping("/{qualityIds}")
    public AjaxResult remove(@PathVariable Long[] qualityIds)
    {
        return toAjax(gcQualityService.deleteGcQualityByQualityIds(qualityIds));
    }
}
